<?php
namespace App\Controller;
class IndexController extends BaseController {
    
    //首页
    public function index(){
       $this->redirect('capacity/learnstyles');
    }

     public function adminajax(){
        $names = empty($_POST['name'])?time():$_POST['name'];
        $db = M('info_results');
        $user=$db->where(array("name"=>$names))->find();
        if(!empty($user)){
          $this->ajaxReturn(3);
        }
        $list = $_POST['list'];
        
        foreach($list as $key=>$v){
            $data['name'] = $names;
            $data['results'] = $v['value'];
            $data['title'] = $v['title'];
            $data['type'] = 1;
            $data['time'] = date("Y-m-d H:i:s");
            if($key<14){
               $db->add($data);
            }
            if($key==14){
               $data['type'] = 2;
               $db->add($data);
            }
        }
        $this->ajaxReturn(1);
    } 
}